package com.jumi.microservice.controller.admin;

import com.alibaba.excel.EasyExcel;
import com.jumi.microservice.common.base.BaseController;
import com.jumi.microservice.common.base.dto.ExportExcelCommonResponse;
import com.jumi.microservice.common.base.dto.ResponseResult;
import com.jumi.microservice.common.constant.RequestConstant;
import com.jumi.microservice.common.page.TableDataInfo;
import com.jumi.microservice.dto.usercash.*;
import com.jumi.microservice.service.admin.AdminUserCashService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

/**
 * @author Scw
 * @Date 2020-07-23 11:46
 */
@Api(tags = {"后台提现管理相关接口"})
@RestController
@RequestMapping("admin/userCash")
public class AdminUserCashController extends BaseController {
    @Resource
    private AdminUserCashService adminUserCashService;

    @PostMapping("/export/excel")
    @ApiOperation("导出excel")
    public void exportExcel(ExportUserCashRequest request, HttpServletResponse response) throws IOException {
        ExportExcelCommonResponse<ExportUserCashResponse> exportUserCashResponseExportExcelCommonResponse = adminUserCashService.exportExcel(request);
        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel");
        response.setCharacterEncoding("utf-8");
        response.setHeader("Content-disposition", "attachment;filename="+ exportUserCashResponseExportExcelCommonResponse.getFileName());
        EasyExcel.write(response.getOutputStream(),ExportUserCashResponse.class).sheet("sheet1").doWrite(exportUserCashResponseExportExcelCommonResponse.getData());
    }

    @GetMapping("/userCashList")
    @ApiOperation("提现列表")
    TableDataInfo<UserCashListResponse> userCashList(UserCashListRequest userCashListRequest) {
        return adminUserCashService.userCashList(userCashListRequest);
    }

    @GetMapping("/cashType/dictionary")
    @ApiOperation("提现账户类型对照字典")
    public ResponseResult<Map<Integer, String>> getCashType() {
        ResponseResult<Map<Integer, String>> result = new ResponseResult<>();
        result.setData(adminUserCashService.getCashType());
        return result;
    }

    @GetMapping("/status/dictionary")
    @ApiOperation("提现状态对照字典")
    public ResponseResult<Map<Integer, String>> getStatus() {
        ResponseResult<Map<Integer, String>> result = new ResponseResult<>();
        result.setData(adminUserCashService.getStatus());
        return result;
    }

    @GetMapping("/checkStatus/dictionary")
    @ApiOperation("审核状态对照字典")
    public ResponseResult<Map<Integer, String>> getCheckStatus() {
        ResponseResult<Map<Integer, String>> result = new ResponseResult<>();
        result.setData(adminUserCashService.getCheckStatus());
        return result;
    }

    @GetMapping(value = "/checkInfo")
    @ApiOperation("审核信息")
    public ResponseResult<UserCashCheckInfoResponse> checkInfo(UserCashIdRequest userCashIdRequest) {
        ResponseResult<UserCashCheckInfoResponse> result = new ResponseResult<>();
        result.setData(adminUserCashService.checkInfo(userCashIdRequest));
        return result;
    }

    @PostMapping(value = "/checkRefuse")
    @ApiOperation("审核拒绝")
    public ResponseResult<Boolean> checkRefuse(UserCashCheckRefuseRequest userCashCheckRefuseRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        userCashCheckRefuseRequest.setOperatorId(getUid());
        userCashCheckRefuseRequest.setOperatorName(getUserName());
        result.setData(adminUserCashService.checkRefuse(userCashCheckRefuseRequest));
        return result;
    }

    @PostMapping(value = "/checkAgree")
    @ApiOperation("审核同意并打款")
    public ResponseResult<Boolean> checkAgree(UserCashCheckAgreeRequest userCashCheckAgreeRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        userCashCheckAgreeRequest.setOperatorId(getUid());
        userCashCheckAgreeRequest.setOperatorName(getUserName());
        result.setData(adminUserCashService.checkAgree(userCashCheckAgreeRequest));
        return result;
    }

    @PostMapping(value = "/checkAgreeBatch")
    @ApiOperation("批量审核同意并打款")
    public ResponseResult<Boolean> checkAgreeBatch(UserCashCheckAgreeBatchRequest userCashCheckAgreeBatchRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        userCashCheckAgreeBatchRequest.setOperatorId(getUid());
        userCashCheckAgreeBatchRequest.setOperatorName(getUserName());
        result.setData(adminUserCashService.checkAgreeBatch(userCashCheckAgreeBatchRequest));
        return result;
    }

    @PostMapping(value = "/checkAgreeAll")
    @ApiOperation("全部审核同意并打款")
    public ResponseResult<Boolean> checkAgreeAll(UserCashCheckAgreeAllRequest userCashCheckAgreeAllRequest) {
        ResponseResult<Boolean> result = new ResponseResult<>();
        userCashCheckAgreeAllRequest.setOperatorId(getUid());
        userCashCheckAgreeAllRequest.setOperatorName(getUserName());
        result.setData(adminUserCashService.checkAgreeAll(userCashCheckAgreeAllRequest));
        return result;
    }

    @GetMapping(value = "/yzh/orderQuery")
    @ApiOperation("云账户-订单查询")
    public ResponseResult<String> orderQuery(OrderQueryRequest orderQueryRequest) {
        ResponseResult<String> result = new ResponseResult<>();
        result.setData(adminUserCashService.orderQuery(orderQueryRequest));
        return result;
    }

//    @GetMapping(value = "/yzh/cancelOrder")
//    @ApiOperation("云账户-取消待打款订单")
//    public ResponseResult<String> cancelOrder(OrderQueryRequest orderQueryRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.cancelOrder(orderQueryRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/dealerBalanceQuery")
//    @ApiOperation("云账户-查询商户余额")
//    public ResponseResult<String> dealerBalanceQuery() {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.dealerBalanceQuery());
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/receiptQuery")
//    @ApiOperation("云账户-查询电⼦回单")
//    public ResponseResult<String> receiptQuery(ReceiptQueryRequest receiptQueryRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.receiptQuery(receiptQueryRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/dailyOrderFileQuery")
//    @ApiOperation("云账户-查询⽇订单⽂件")
//    public ResponseResult<String> dailyOrderFileQuery(OrderDateRequest orderDateRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.dailyOrderFileQuery(orderDateRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/dailyBillFileQuery")
//    @ApiOperation("云账户-查询日流水文件")
//    public ResponseResult<String> dailyBillFileQuery(OrderDateRequest orderDateRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.dailyBillFileQuery(orderDateRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/rechargeRecordQuery")
//    @ApiOperation("云账户-查询商户充值记录")
//    public ResponseResult<String> rechargeRecordQuery(RechargeRecordRequest rechargeRecordRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.rechargeRecordQuery(rechargeRecordRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/realNameVerify")
//    @ApiOperation("云账户-身份证实名验证")
//    public ResponseResult<String> realNameVerify(RealNameRequest realNameRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.realNameVerify(realNameRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/exemptedInfoListQuery")
//    @ApiOperation("云账户-查看用户免验证名单是否存在")
//    public ResponseResult<String> exemptedInfoListQuery(RealNameRequest realNameRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.exemptedInfoListQuery(realNameRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/bankCardInfoQuery")
//    @ApiOperation("云账户-查询银行卡信息")
//    public ResponseResult<String> bankCardInfoQuery(CardInfoRequest cardInfoRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.bankCardInfoQuery(cardInfoRequest));
//        return result;
//    }
//
//    @GetMapping(value = "/yzh/invoiceStatQuery")
//    @ApiOperation("云账户-查询商户已开具发票金额和待开具发票金额")
//    public ResponseResult<String> invoiceStatQuery(YearRequest yearRequest) {
//        ResponseResult<String> result = new ResponseResult<>();
//        result.setData(adminUserCashService.invoiceStatQuery(yearRequest));
//        return result;
//    }
}
